package com.atguigu.lease.common.Advice;

import com.atguigu.lease.common.result.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
public class GlobalExceptionHandlers {
    @ExceptionHandler(Exception.class)
    public Result<String> exceptionHandler(Exception e){
        e.printStackTrace();// 打印异常信息
        return Result.fail(e.getMessage());// 返回错误信息
    }
    @ExceptionHandler(LeaseException.class)
    public Result<String> leaseExceptionHandler(LeaseException e){
        e.printStackTrace();// 打印异常信息
        return Result.fail(e.getCode(),e.getMessage());// 返回错误信息
    }
}
